import React from 'react'
import { Toast } from 'antd-mobile'
import * as api from './server'
import $ from 'jquery'
export const Public = () => {
    const createTopic = () => {
        let { token } = JSON.parse(localStorage.getItem('userInfo'))

        let title = $('input').val()
        let text = $('textarea').val()
        //$('div').css('color', 'red')
        let obj = {
            accesstoken: token,
            title: title,
            tab: 'dev',
            content: text
        }
        console.log(obj)
        api.createTopic(obj)
            .then(res => {
                if (res.success) {
                    Toast.show({
                        icon: 'success',
                        content: '发布成功'
                    })
                }

            })
    }
    return (
        <div className='box' style={{width:"100%"}}>
            <br />
            请选择模块：
            <select style={{width:"50%"}}>
                <option value='share'>share</option>
                <option value='ask'>ask</option>
                <option value='job'>job</option>
                <option value='dev' >dev</option>
            </select>
            <br /><br />
            <input type='text' style={{width:"70%"}} placeholder='标题字数10字以上'/> <br /><br />
            <textarea id='text' cols="30" rows="10" style={{width:"90%"}}></textarea> <br /><br />
            <button onClick={createTopic}>发布</button>
        </div>
    )
}
